import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserBankVO, UserBankForm, UserBankQuery } from '@/api/system/userBank/types';

/**
 * 查询银行信息列表
 * @param query
 * @returns {*}
 */

export const listUserBank = (query?: UserBankQuery): AxiosPromise<UserBankVO[]> => {
  return request({
    url: '/electroniccommerce/bank/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询银行信息详细
 * @param id
 */
export const getUserBank = (id: string | number): AxiosPromise<UserBankVO> => {
  return request({
    url: '/electroniccommerce/bank/' + id,
    method: 'get'
  });
};

/**
 * 新增银行信息
 * @param data
 */
export const addUserBank = (data: UserBankForm) => {
  return request({
    url: '/electroniccommerce/bank',
    method: 'post',
    data: data
  });
};

/**
 * 修改银行信息
 * @param data
 */
export const updateUserBank = (data: UserBankForm) => {
  return request({
    url: '/electroniccommerce/bank',
    method: 'put',
    data: data
  });
};

/**
 * 删除银行信息
 * @param id
 */
export const delUserBank = (id: string | number | Array<string | number>) => {
  return request({
    url: '/electroniccommerce/bank/' + id,
    method: 'delete'
  });
};
